package collection;

import java.util.*;

public class SortInteger {
    public static void main(String[] args) {
        Random random = new Random();
        Scanner scanner = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        System.out.println("输入你所需要的数组长度：");
        int len = scanner.nextInt();
        for (int i = 0; i < len; i++) {
            list.add(random.nextInt(100));
        }
        System.out.println("原集合数据："+list);

        Collections.sort(list);//自然排序，从小到大
        System.out.println("排序后的数据："+list);
        System.out.println("第一个元素为："+list.get(0));

        Collections.reverse(list);//反转list集合
        System.out.println("反转后的数据："+list);
        System.out.println("第一个元素为："+list.get(0));
    }
}
